//引入字体图标
require('../../assets/font/font_3852666_7r0dooui378/iconfont.css')
//渲染tabbar函数
function renderTabbar(pathname) {
  //获取当前地址
  //console.log('location.pathname :>> ', location.pathname)

  let arr = [
    {
      path: './home.html',
      title: '首页',
      icon: 'icon-shouye',
    },
    {
      path: './sports.html',
      title: '运动',
      icon: 'icon-xindiantu',
    },
    {
      path: './circle.html',
      title: '圈子',
      icon: 'icon-quanzi',
    },
    {
      path: './my.html',
      title: '我的',
      icon: 'icon-wode',
    },
  ]
  let html = `
        ${arr
          .map((v, i) => {
            return `<a href="${v.path}" class="item df fdc aic ${
              v.path ===`./${pathname}.html`  && 'active'
            }">
            <i class="iconfont ${v.icon}"></i>
            <span>${v.title}</span>
        </a>`
          })
          .join('')}
    `
  //创建一个div
  let div = document.createElement('div')
  //设置div的class
  div.className = 'tabbar fn df jcsb aic'
  //给div里面填充内容
  div.innerHTML = html
  //body把div添加进最后
  document.body.appendChild(div)
}

//导出tabbar渲染函数
module.exports = renderTabbar
